package com.itsv.news.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itsv.news.R;
import com.itsv.news.bean.RssMessageBean;

public class RssListAdapter extends BaseAdapter {

	private Context con = null;
	private LayoutInflater inflater = null;

	private TextView tv_title = null;
	private TextView tv_time = null;
	public ArrayList<RssMessageBean> list = null;
	private RssMessageBean bean = null;

	public RssListAdapter(Context con) {
		this.con = con;
		inflater = LayoutInflater.from(con);
	}

	public void setData(ArrayList<RssMessageBean> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.rss_item, null);

		}
		tv_title = (TextView) convertView.findViewById(R.id.tv_rssitem_title);

		tv_time = (TextView) convertView.findViewById(R.id.tv_rssitem_time);

		bean = list.get(position);
		Log.v("test", "title:" + bean.getTitle());
		tv_title.setText(bean.getTitle());
		tv_time.setText(bean.getDate());
		return convertView;
	}

}
